package com.bub.pay.core.manager.client.impl;

import com.bub.pay.core.manager.client.ClientManager;
import com.bub.pay.framework.redis.model.JPushModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.redis.listener.ChannelTopic;

import com.bub.pay.framework.redis.RedisClient;
import com.bub.pay.framework.redis.model.EmailModel;
import com.bub.pay.framework.redis.model.HttpModel;
import com.bub.pay.framework.redis.model.SmsModel;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ClientManagerImpl implements ClientManager {

	@Autowired
	@Qualifier(value = "smsTopic")
	private ChannelTopic smsTopic;

	@Autowired
	@Qualifier(value = "emailTopic")
	private ChannelTopic emailTopic;

	@Autowired
	@Qualifier(value = "clientTopic")
	private ChannelTopic clientTopic;

	@Autowired
	@Qualifier(value = "jPushTopic")
	private ChannelTopic jPushTopic;

	@Resource
	private RedisClient redisClient;

	@Override
	public void sendSms(SmsModel model) {
		redisClient.pubMessage(smsTopic, model);
	}

	@Override
	public void sendEmail(EmailModel model) {
		redisClient.pubMessage(emailTopic, model);
	}

	@Override
	public void sendHttp(HttpModel model) {
		redisClient.pubMessage(clientTopic, model);
	}

	@Override
	public void pushMessage(JPushModel model) {
		redisClient.pubMessage(jPushTopic, model);
	}
}
